var SEAT = "seat";
var seatId = 0;

$.extend(true, Seat.prototype, objectBase);


// Class for creating custom rectangular shapes like bar
function Seat(options) {

    // Default Options
    var defaultOptions = {
        id: "s" + (seatId++),
        top: 0,
        left: 0,
        size: 14,
        orientation: 0,
        background: "white",
        border: "1px solid black",
        radius: 4,
        reservable: true
    };

    // Create current configuration
    this.state = $.extend(true, defaultOptions, options);
}

// Method for creating HTML element
Seat.prototype.getElement = function () {
    if (this.element){
        return this.element
    }
    var element;

    element = $("<div/>");
    this.updateElement(element);

    return element;
};

// Method providing access to move with the object
Seat.prototype.resize = function (width, height){
    this.getElement().width(width);
    this.getElement().height(height);
};

Seat.prototype.getWidth = function (){
    return this.state.size;
};

Seat.prototype.getHeight = function (){
    return this.state.size;
};

Seat.prototype.setState = function (state){
    this.state = state;
    this.updateElement(this.element);
};

Seat.prototype.updateElement = function (element){
    element.empty();
    element.width(this.state.size);
    element.height(this.state.size);

    element.attr("data-type", SEAT);
    element.attr("id", this.state.id);

    element.css("position", "absolute");
    element.css("left", this.state.left + "px");
    element.css("top", this.state.top + "px");
    element.css("background", this.state.background);

    if (this.state.border){
        element.css("border", this.state.border);
        element.css("border-radius", this.state.radius + "px");
        element.css("moz-border-radius", this.state.radius + "px");
    }

    if (this.state.orientation){
        element.css("transform", "rotate(" + this.state.orientation + "deg)");
        element.css("-o-transform", "rotate(" + this.state.orientation + "deg)");
        element.css("-ms-transform", "rotate(" + this.state.orientation + "deg)");
        element.css("-moz-transform", "rotate(" + this.state.orientation + "deg)");
        element.css("-webkit-transform", "rotate(" + this.state.orientation + "deg)");
    }

    if (this.state.reservable){
        element.addClass("reservable");
    } else {
        element.removeClass("reservable");
    }

    this.element = element;
}